﻿using System;
using UnityEngine;

namespace TC
{
    [Serializable]
    public abstract class Variable
    {
        public virtual byte AsByte() { throw new Exception("not implemented !"); }
        public virtual short AsShort() { throw new Exception("not implemented !"); }
        public virtual int AsInt() { throw new Exception("not implemented !"); }
        public virtual long AsLong() { throw new Exception("not implemented !"); }
        public virtual float AsFloat() { throw new Exception("not implemented !"); }
        public virtual double AsDouble() { throw new Exception("not implemented !"); }
        public virtual char AsChar() { throw new Exception("not implemented !"); }
        public virtual string AsString() { throw new Exception("not implemented !"); }
        public virtual bool AsBool() { throw new Exception("not implemented !"); }
        public virtual Vector4 AsVector4() { throw new Exception("not implemented !"); }
        public virtual Vector3 AsVector3() { throw new Exception("not implemented !"); }
        public virtual Vector2 AsVector2() { throw new Exception("not implemented !"); }
        public virtual Transform AsTransform() { throw new Exception("not implemented !"); }
        public virtual T AsObject<T>() { throw new Exception("not implemented !"); }

        public virtual bool Convert(Variable i) { throw new Exception("not implemented !"); }
    }

    [Serializable]
    public class ByteVar : Variable
    {
        public byte value;

        public ByteVar(byte value)
        {
            this.value = value;
        }

        public override byte AsByte()
        {
            return value;
        }

        public override bool Convert(Variable i)
        {
            if(i is IntVar)
            {

            }

            return true;
        }
    }

    [Serializable]
    public class ShortVar : Variable
    {
        public short value;

        public ShortVar(short value)
        {
            this.value = value;
        }

        public override short AsShort()
        {
            return value;
        }
    }

    [Serializable]
    public class IntVar : Variable
    {
        public int value;

        public IntVar(int value)
        {
            this.value = value;
        }

        public override int AsInt()
        {
            return value;
        }
    }

    [Serializable]
    public class LongVar : Variable
    {
        public long value;

        public LongVar(long value)
        {
            this.value = value;
        }

        public override long AsLong()
        {
            return value;
        }
    }

    [Serializable]
    public class FloatVar : Variable
    {
        public float value;

        public FloatVar(float value)
        {
            this.value = value;
        }

        public override float AsFloat()
        {
            return value;
        }
    }

    [Serializable]
    public class DoubleVar : Variable
    {
        public double value;

        public DoubleVar(double value)
        {
            this.value = value;
        }

        public override double AsDouble()
        {
            return value;
        }
    }

    [Serializable]
    public class CharVar : Variable
    {
        public char value;

        public CharVar(char value)
        {
            this.value = value;
        }

        public override char AsChar()
        {
            return value;
        }
    }

    [Serializable]
    public class BoolVar : Variable
    {
        public bool value;

        public BoolVar(bool value)
        {
            this.value = value;
        }

        public override bool AsBool()
        {
            return value;
        }
    }

    [Serializable]
    public class VectorVar : Variable
    {
        public Vector4 value;

        public VectorVar(Vector2 value)
        {
            this.value = value;
        }

        public VectorVar(Vector3 value)
        {
            this.value = value;
        }

        public VectorVar(Vector4 value)
        {
            this.value = value;
        }

        public override Vector2 AsVector2()
        {
            return value;
        }

        public override Vector3 AsVector3()
        {
            return value;
        }

        public override Vector4 AsVector4()
        {
            return value;
        }
    }

    [Serializable]
    public class ObjectVar : Variable
    {
        public object value;

        public ObjectVar(object value)
        {
            this.value = value;
        }

        public override T AsObject<T>()
        {
            return (T)value;
        }
    }
}
